package com.kaizeli.website.entity;

import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 员工JPA实体类 - 用于自动建表和更新表结构
 * 基于现有的EmployeeDO字段定义
 */
@Data
@Entity
@Table(name = "employee", 
       indexes = {
           @Index(name = "idx_employee_type", columnList = "employeeType"),
           @Index(name = "idx_marital_status", columnList = "maritalStatus"),
           @Index(name = "idx_political_status", columnList = "politicalStatus"),
           @Index(name = "idx_education", columnList = "education"),
           @Index(name = "idx_graduation_date", columnList = "graduationDate")
       })
public class EmployeeEntity {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @Comment("主键ID")
    private Long id;
    
    @Column(name = "project_code", length = 64)
    @Comment("项目编号")
    private String projectCode;
    
    @Column(name = "client_unit", length = 200)
    @Comment("客户单位")
    private String clientUnit;
    
    @Column(name = "department", length = 100)
    @Comment("所在部门")
    private String department;
    
    @Column(name = "team", length = 100)
    @Comment("所在团队")
    private String team;
    
    @Column(name = "position", length = 100)
    @Comment("岗位名称")
    private String position;
    
    @Column(name = "employee_type", length = 20)
    @Comment("员工类型(正式/实习/见习)")
    private String employeeType;
    
    @Column(name = "name", length = 100)
    @Comment("员工姓名")
    private String name;
    
    @Column(name = "gender", length = 10)
    @Comment("性别(男/女)")
    private String gender;
    
    @Column(name = "marital_status", length = 10)
    @Comment("婚姻状况(已婚/未婚)")
    private String maritalStatus;
    
    @Column(name = "native_place", length = 100)
    @Comment("籍贯")
    private String nativePlace;
    
    @Column(name = "ethnicity", length = 50)
    @Comment("民族")
    private String ethnicity;
    
    @Column(name = "political_status", length = 50)
    @Comment("政治面貌")
    private String politicalStatus;
    
    @Column(name = "id_card", length = 18)
    @Comment("身份证号")
    private String idCard;
    
    @Column(name = "birthday")
    @Comment("生日")
    private LocalDate birthday;
    
    @Column(name = "registered_address", length = 500)
    @Comment("户籍地址")
    private String registeredAddress;
    
    @Column(name = "current_address", length = 500)
    @Comment("现居住地址")
    private String currentAddress;
    
    @Column(name = "phone", length = 20)
    @Comment("联系电话")
    private String phone;
    
    @Column(name = "wechat", length = 100)
    @Comment("微信号")
    private String wechat;
    
    @Column(name = "email", length = 100)
    @Comment("邮箱")
    private String email;
    
    @Column(name = "employee_code", length = 50)
    @Comment("员工编号（工号）")
    private String employeeCode;
    
    @Column(name = "hire_date")
    @Comment("入职时间")
    private LocalDate hireDate;
    
    @Column(name = "confirmation_date")
    @Comment("转正时间")
    private LocalDate confirmationDate;
    
    @Column(name = "probation", length = 20)
    @Comment("试用状态(试用期/已转正)")
    private String probation;
    
    @Column(name = "status")
    @Comment("员工状态（1在职，0离职）")
    private Integer status;
    
    @Column(name = "education", length = 50)
    @Comment("学历")
    private String education;
    
    @Column(name = "major", length = 100)
    @Comment("所学专业")
    private String major;
    
    @Column(name = "university", length = 200)
    @Comment("毕业院校")
    private String university;
    
    @Column(name = "graduation_date")
    @Comment("毕业时间")
    private LocalDate graduationDate;
    
    @Column(name = "skill_certificates", columnDefinition = "TEXT")
    @Comment("技能证书")
    private String skillCertificates;
    
    @Column(name = "base_salary", precision = 10, scale = 2)
    @Comment("基本工资")
    private BigDecimal baseSalary;
    
    @Column(name = "hourly_rate", precision = 10, scale = 2)
    @Comment("小时工资率（用于计算人工费用）")
    private BigDecimal hourlyRate;
    
    @Column(name = "emergency_contact", length = 100)
    @Comment("紧急联系人")
    private String emergencyContact;
    
    @Column(name = "emergency_phone", length = 20)
    @Comment("紧急联系电话")
    private String emergencyPhone;
    
    @Column(name = "bank_account", length = 50)
    @Comment("银行卡号")
    private String bankAccount;
    
    @Column(name = "bank_name", length = 200)
    @Comment("开户行")
    private String bankName;
    
    @Column(name = "contract_renewed", length = 10)
    @Comment("是否已续签合同")
    private String contractRenewed;
    
    @Column(name = "renewal_count")
    @Comment("续签合同次数")
    private Integer renewalCount;
    
    @Column(name = "latest_contract_start")
    @Comment("最新合同开始时间")
    private LocalDate latestContractStart;
    
    @Column(name = "latest_contract_end")
    @Comment("最新合同结束时间")
    private LocalDate latestContractEnd;
    
    @Column(name = "contract_company", length = 200)
    @Comment("签合同公司")
    private String contractCompany;
    
    @Column(name = "entry_form", length = 500)
    @Comment("入职登记表")
    private String entryForm;
    
    @Column(name = "id_card_copy", length = 500)
    @Comment("身份证复印件")
    private String idCardCopy;
    
    @Column(name = "diploma", length = 500)
    @Comment("学历毕业证书")
    private String diploma;
    
    @Column(name = "degree_certificate", length = 500)
    @Comment("学位证书")
    private String degreeCertificate;
    
    @Column(name = "bank_card_copy", length = 500)
    @Comment("银行卡复印件")
    private String bankCardCopy;
    
    @Column(name = "resume", length = 500)
    @Comment("简历")
    private String resume;
    
    @Column(name = "leaving_certificate", length = 500)
    @Comment("离职证明")
    private String leavingCertificate;
    
    @Column(name = "medical_report", length = 500)
    @Comment("三甲体检报告")
    private String medicalReport;
    
    @Column(name = "confidentiality_agreement", length = 500)
    @Comment("保密协议")
    private String confidentialityAgreement;
    
    @Column(name = "training_agreement", length = 500)
    @Comment("员工培训协议")
    private String trainingAgreement;
    
    @Column(name = "rules_confirmation", length = 500)
    @Comment("规章制度确认书")
    private String rulesConfirmation;
    
    @Column(name = "code_of_conduct", length = 500)
    @Comment("员工行为准则")
    private String codeOfConduct;
    
    @Column(name = "remarks", columnDefinition = "TEXT")
    @Comment("备注")
    private String remarks;
    
    @Column(name = "create_time", nullable = false, updatable = false)
    @Comment("创建时间")
    private LocalDateTime createTime;
    
    @Column(name = "update_time", nullable = false)
    @Comment("更新时间")
    private LocalDateTime updateTime;
    
    @PrePersist
    protected void onCreate() {
        createTime = LocalDateTime.now();
        updateTime = LocalDateTime.now();
    }
    
    @PreUpdate
    protected void onUpdate() {
        updateTime = LocalDateTime.now();
    }
}
